package com.xrui.hbase.schema;

import com.google.common.base.Objects;

public class RowKeyComponent {

    private String mName;
    private ComponentType mType;
    private boolean mHashed;

    public static RowKeyComponent create(String name, ComponentType componentType, boolean hashed) {
        RowKeyComponent component = new RowKeyComponent();
        component.setName(name);
        component.setType(componentType);
        component.setHashed(hashed);
        return component;
    }

    public static RowKeyComponent create(String name, ComponentType componentType) {
        return create(name, componentType, false);
    }

    public String getName() {
        return mName;
    }

    public void setName(String mName) {
        this.mName = mName;
    }

    public ComponentType getType() {
        return mType;
    }

    public void setType(ComponentType mType) {
        this.mType = mType;
    }

    public boolean isHashed() {
        return mHashed;
    }

    public void setHashed(boolean mHashed) {
        this.mHashed = mHashed;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(RowKeyComponent.class)
            .add("name", mName)
            .add("type", mType)
            .add("hashed", mHashed)
            .toString();
    }

    public enum ComponentType {
        STRING,
        INTEGER,
        LONG
    }
}
